<%--
  Created by IntelliJ IDEA.
  User: hasee
  Date: 2018/4/27
  Time: 23:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>cookie</title>
</head>
<body>
    <%
        //写入Cookie
        String name = "yang";
        Cookie c = new Cookie("name",name);
        response.addCookie(c);

        //读取Cookie
        Cookie cookie[] = request.getCookies();
        for (int i = 0;i < cookie.length;i++) {
            if (cookie[i].getName().equals(name))
                out.print(cookie[i].getValue());
        }
    %>
</body>
</html>
